"""
服务端：接收客户端来的图片
"""
from socket import *

# 1.初始化信息
ip = "127.0.0.1"
port = 22345
address = (ip, port)


# 2.创建socekt
server_socekt = socket(AF_INET, SOCK_STREAM)
server_socekt.bind(address)
server_socekt.listen(5)
print("服务端已经建立，等待客户端的链接。。。。")
# 3.接收客户端的请求
client_socket, client_address = server_socekt.accept()
print("已有客户端连入：%s" % str(client_address))


# 3.读取本地的图片-->服务端
# step1：获取文件对象
# step2：操作文件对象，读取数据
# step3：将读到的数据，写出

file = open(r"C:\Users\Administrator\Desktop\aa.jpg", mode="rb")
img_data = file.read()  # 读取所有
client_socket.send(img_data)




client_socket.close()
server_socekt.close()
